import 'package:eplorex/utils/ColorUtil.dart';
import 'package:flutter/material.dart';

import '../pages/my/profile/ButtonWidget.dart';

class AppBarWidget extends StatefulWidget implements PreferredSizeWidget {
  const AppBarWidget({super.key, required this.context, required this.onConfirmed, required this.title,});

  final BuildContext context;

  final String title;

  final VoidCallback onConfirmed;

  @override
  State<AppBarWidget> createState() => _AppBarWidgetState();

  @override
  // TODO: implement preferredSize
  Size get preferredSize => Size.fromHeight(45);
}

class _AppBarWidgetState extends State<AppBarWidget> {
  @override
  Widget build(BuildContext context) {
    return AppBar(
      leading:  ButtonWidget(
        width: 80,
        height: 50,
        onPressed: () {
          Navigator.pop(context);
        },
        highlightedColor: ColorUtil.hexColor(0xf7f7f7),
        bgColor: ColorUtil.hexColor(0xffffff),
        bgHighlightedColor: ColorUtil.hexColor(0xf7f7f7),
        enabled: true,
        bgDisableColor: Colors.grey,
        borderRadius: 8.0,
        child: Text(
          "取消",
          textAlign: TextAlign.center,
          softWrap: true,
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.w500,
            fontStyle: FontStyle.normal,
            color: ColorUtil.hexColor(0xA1A1A1),
            decoration: TextDecoration.none,
          ),
        ),
      ),
      title: Text(widget.title),actions: [
      ButtonWidget(
        width: 80,
        height: 50,
        onPressed: () {
          Navigator.pop(context);
          widget.onConfirmed.call();
        },
        highlightedColor: ColorUtil.hexColor(0xf7f7f7),
        bgColor: ColorUtil.hexColor(0xffffff),
        bgHighlightedColor: ColorUtil.hexColor(0xf7f7f7),
        enabled: true,
        bgDisableColor: Colors.grey,
        borderRadius: 8.0,
        child: Text(
          "确定",
          textAlign: TextAlign.center,
          softWrap: true,
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.w400,
            fontStyle: FontStyle.normal,
            color: ColorUtil.hexColor(0x338FFF),
            decoration: TextDecoration.none,
          ),
        ),
      )
    ],);
  }
}
